package com.chis.child;

import com.chis.jm.bean.InocThreeInfo;
import com.chis.jm.bean.ResultStrBean;
import com.chis.jm.pojo.Inoculation;

import hprose.client.HproseHttpClient;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * Created by jmw on 2016-09-07.
 */
public class ChildInocTest {
    public static void main(String[] args) throws Exception {
        ChildInocTest t = new ChildInocTest();
        HproseHttpClient client = new HproseHttpClient();
        client.useService("http://218.90.131.150:58022/JmYfjzService/managerChildCard");
//        client.useService("http://10.88.88.142:7001/JmYfjzService/managerChildCard");
        client.setHeader("jmversion", "1.1");

//      //3.3更新本地儿童免疫史接口（市平台）
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

        t.updateChildYfjz(client);

//      //3.4删除本地儿童免疫史接口（市平台）
//        t.delChildYfjz(client);

        //3.5删除异地儿童免疫史接口（市平台）
//        t.delOthChildYfjz(client);
        
        System.out.println(sdf.format(new Date()));
    }

    /**
     * 3.3更新本地儿童免疫史接口（市平台）
     * @param client
     * @throws Exception
     */
    public void updateChildYfjz(HproseHttpClient client) throws Exception {
//        Long unitCode = 3202031401L;			//单位编码
//        String unitLoginPwd = "32020314012017090614";		//单位登录密码
//        Long userNo = 3202031401001L;

        Long unitCode = 3202060302L;            //单位编码
        String unitLoginPwd = "32020603022019031314";        //单位登录密码
        Long userNo = 3202060302001L;

        Long ChilCode = 320206030220150015l; //5df68b59-8439-4d9d-9541-c7a0e06ebb43  320207040120150011l  18f51880-ef25-4dc0-bba9-303b1734c9f6 320207040120150010l
//        Long unitCode = 3205080101L;            //单位编码
//        String unitLoginPwd = "32050801012018121119";        //单位登录密码
//        Long userNo = 3205080101099L;
//
//        Long ChilCode = 320508010119948695l; //5df68b59-8439-4d9d-9541-c7a0e06ebb43  320207040120150011l  18f51880-ef25-4dc0-bba9-303b1734c9f6 320207040120150010l

        int tag = 2;  //1-新增、2-修改
        List<Inoculation> inoculationList = new ArrayList<>();      //免疫史列表
        List<InocThreeInfo> inoThreeList = new ArrayList<>();       //连带免疫史列表
        Inoculation inoc1 = new Inoculation();
        inoc1.setInocGuid(UUID.randomUUID().toString());    //GUID
        System.out.println(inoc1.getInocGuid());
        inoc1.setInocChilId(ChilCode);
        inoc1.setInocBactCode("020101");
        inoc1.setInocTime(1);
        inoc1.setInocDate((new Date("2018/11/04")));
        inoc1.setIfFic((short) 0);
        inoc1.setCreateDate(new Date("2019/01/01"));
        inoc1.setCreateManCode(userNo);
        inoc1.setIfSzhmz(0);
//        inoc1.setInocCorpCode("");
        inoc1.setRegManCode(userNo);
        inoc1.setInocProperty("1");
        inoc1.setRecUnitCode(unitCode);
        inoc1.setInocDepaCode(unitCode);
//        inoc1.setInocInplCode("2");
//        inoc1.setInocCorpCode("null");
        inoc1.setPjRst(1);
        inoc1.setInocPrdType((short) 2);
        inoc1.setInocIfprov(0);
        inoc1.setModifyManCode(userNo);
        inoc1.setModifyDate((new Date("2019/01/01 14:44:00")));
        inoc1.setInocFree(0);
        inoc1.setInocMoney(BigDecimal.valueOf(-99));
//        inoc1.setFwMoney(BigDecimal.valueOf(0.0)); //服务费
        inoc1.setCyMoney(BigDecimal.valueOf(20.7)); //储运费
        inoc1.setInocCorpName("罗益（无锡）生物制药有限公司"); //疫苗生产企业名称
        inoc1.setIfDefChnl(1); //是否默认接种途径
        inoc1.setInocDepaName("坊前"); //接种单位名称
        inoc1.setRecUnitName("坊前"); //录入单位名称
        inoc1.setRegManName("小张");  //登记医生姓名
//        inoc1.setInocManName("小张"); //接种医生姓名
//        inoc1.setChilNo("320211201801119729"); //儿童身份证
        inoc1.setRegManNo("610524198702180025"); //登记医生身份证
//        inoc1.setInocManNo("610524198702180025"); //接种医生身份证
        inoc1.setInocDelmark(0);
        inoc1.setBactChnl("1");  //接种途径编码
        inoc1.setActuTime(1);
        inoc1.setIfEffec((short)1);     //1有效，0未知，2无效
        inoc1.setInocPrdType((short) 1);
        inoc1.setRegManCode(userNo);
        inoc1.setInocManCode(userNo);
        inoculationList.add(inoc1);

        if (inoThreeList.size() == 0) {
            inoThreeList = null;
        }

        //"e1dfd280-5e31-425a-96df-81b63a1a4501"
//        InocThreeInfo t = new InocThreeInfo();
//        t.setGuid("e1dfd280-5e31-425a-96df-81b63a1a4501");
//        t.setInocTime(1);
//        t.setIfEffec((short)2);
//        t.setActuTime(1);
//        t.setPjRst(-1);
//        inoThreeList.add(t);

        try {
            ResultStrBean r = (ResultStrBean) client.invoke("updateChildYfjz", new Object[]{unitCode, unitLoginPwd, tag, inoculationList, inoThreeList, ChilCode, userNo});
            System.out.println("返回代号:" + r.getTypes());
            System.out.println("返回提示内容:" + r.getMsg());
            System.out.println("value:" + r.getValue());
        } catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     * 3.4删除本地儿童免疫史接口（市平台）
     * @param client
     * @throws Exception
     */
    public void delChildYfjz(HproseHttpClient client) throws Exception {


        Long unitCode = 3202060401L;			//单位编码
        String unitLoginPwd = "32020604012018101714";		//单位登录密码
        Long userNo = 3202060401008L;

        Long ChilCode = 320206040120160316l;

        int ifSpecial = 0;

        List<String[]> inocGUIDList = new ArrayList<>();
        String[] array =new  String[2];
        array[0]="4621cdab-8f6b-4d0c-a167-a860c46c4203";
//        array[1]="3C4FA0BA-D7AD-4E62-BFAB-919226C5EB55";
        inocGUIDList.add(array);

        List<InocThreeInfo> inocThreeInfoList = new ArrayList<>();

        InocThreeInfo inoc1 = new InocThreeInfo();
        inoc1.setGuid("4621cdab-8f6b-4d0c-a167-a860c46c4203");
        inoc1.setActuTime(1);
        inoc1.setPjRst(1);
        inoc1.setIfEffec((short) 1);
        inocThreeInfoList.add(inoc1);

        try {
            ResultStrBean r = (ResultStrBean) client.invoke("delChildYfjz", new Object[]{unitCode, unitLoginPwd, inocGUIDList, inocThreeInfoList, ChilCode, ifSpecial, userNo});
            System.out.println("返回代号:" + r.getTypes());
            System.out.println("返回提示内容:" + r.getMsg());
            System.out.println("value:" + r.getValue());
        } catch (Exception e){
            e.printStackTrace();
        }
    }

    
    //3.5删除异地儿童免疫史接口（市平台）
    public void delOthChildYfjz(HproseHttpClient client) throws Exception {
        Long unitCode = 3202060401l;			//单位编码
        String unitLoginPwd = "32020604012018101714";		//单位登录密码
        Long userNo = 3202060401001L;

        Long ChilCode = 320206120120180071l;

        int ifSpecial = 0;
        
        String citytag = "320200";

        List<String[]> inocGUIDList = new ArrayList<>();
        String[] array =new  String[2];
        array[0]="4621cdab-8f6b-4d0c-a167-a860c46c4203";
        array[1]="3C4FA0BA-D7AD-4E62-BFAB-919226C5EB55";
        inocGUIDList.add(array);

        List<InocThreeInfo> inocThreeInfoList = new ArrayList<>();

        InocThreeInfo inoc1 = new InocThreeInfo();
        inoc1.setGuid("4621cdab-8f6b-4d0c-a167-a860c46c4203");
        inoc1.setActuTime(1);
        inoc1.setPjRst(1);
        inoc1.setIfEffec((short) 1);
        inocThreeInfoList.add(inoc1);

        try {
            ResultStrBean r = (ResultStrBean) client.invoke("delOthChildYfjz", new Object[]{unitCode, unitLoginPwd, inocGUIDList, inocThreeInfoList, ChilCode, ifSpecial,citytag, userNo});
            System.out.println("返回代号:" + r.getTypes());
            System.out.println("返回提示内容:" + r.getMsg());
            System.out.println("value:" + r.getValue());
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}
